package jcommon.chap5_collection.map;

import java.util.Map;

import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.ArrayUtils;

public class GetNumber {

	public static void main(String[] args) {
		Object[] mapArray = new Object[][] { { "A", new Double(2.0) },
				{ "B", new Double(0.223242) }, { "C", new Double(2828e4) },
				{ "D", "GARBAGE" } };

		Map numberMap = ArrayUtils.toMap(mapArray);
		double a = MapUtils.getDoubleValue(numberMap, "A");
		double b = MapUtils.getDoubleValue(numberMap, "B");
		double c = MapUtils.getDoubleValue(numberMap, "C");
		double d = MapUtils.getDoubleValue(numberMap, "D", new Double(
				Double.NaN));

		System.out.println("A = " + a);
		System.out.println("B = " + b);
		System.out.println("C = " + c);
		System.out.println("D = " + d);

		System.out.println(1 / 0.0);
		System.out.println(0 / 0.0);
		// System.out.println(1/0); ArithemeticException
		// System.out.println(0/0); ArithemeticException
	}
}
